package cn.xf.web.request;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;

public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {

    private HttpServletRequest request;

    public XssHttpServletRequestWrapper(HttpServletRequest request) {
        super(request);
        this.request = request;
    }

    @Override
    public String getParameter(String name) {
        String oldValue = super.getParameter(name);
        if (StringUtils.isBlank(oldValue)){
            return oldValue;
        }
        String newValue = StringEscapeUtils.escapeHtml4(oldValue);
        return newValue;
    }
}
